<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : looks.xsl
    Created on : August 17, 2013, 4:34 PM
    Author     : Tung An
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes"/>
    <xsl:param name="userId"/>
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template name="look" match="looks">
        <xsl:for-each select="look">
            <xsl:sort select="originaltime" order="descending"/>
            <li id="{lookid}" data="look-item" class="look-item box">
                <div class="look-photo">
                    <img src="{lookimage}"/>
                </div>
                <div class="look-desc">
                    <div class="look-name">
                        <xsl:value-of select="lookname"/>
                    </div>
                    <div class="desc-content">
                        <xsl:choose>
                            <xsl:when test="lookdescription">
                                <xsl:value-of select="lookdescription"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>No description</xsl:text>
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                    <div class="user-info">
                        <div class="avatar">
                            <xsl:if test="avatarurl != ''">
                                <img src="{avatarurl}"/>
                            </xsl:if>
                            <xsl:if test="avatarurl = ''">
                                <img src="/images/default_avatar.png"/>
                            </xsl:if>
                        </div>
                        <div class="info">
                            <div>
                                <span>Posted by</span>
                                <span class="user-name">
                                    <xsl:value-of select="username"/>
                                </span>
                            </div>
                            <div class="update-time">
                                <xsl:value-of select="updatetime"/>
                            </div>
                            <xsl:if test="userid = $userId">
                                <div class="edit" data="edit" title="Edit">
                                    <img src="./images/icon/edit.png"/>
                                </div>
                            </xsl:if>
                        </div>
                    </div>
                </div>
            </li>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
